<template>
  <div>
    <div class="wrap_button">
      <div @click="beforePage">上一页</div>
      <div @click="nextPage">下一页</div>
      <div><a
        href="public/RuYiAdmin开源项目系统使用手册（企业版）.pdf"
        download="RuYiAdmin开源项目系统使用手册（企业版）.pdf"
      >下载</a>
      </div>
    </div>
    <div class="pdf">
      <pdf
        ref="pdf"
        :page="page"
        :src="bps"
        @progress="pdfProcess"
        @page-loaded="overReload"
        @num-pages="numPages"
        @error="errorReload"
      />
    </div>
  </div>
</template>
<script>
import bps from '../../../public/RuYiAdmin开源项目系统使用手册（企业版）.pdf'
import pdf from 'vue-pdf'

export default {
  name: 'Sysdocument',
  components: {
    pdf
  },
  data() {
    return {
      bps,
      page: 1,
      totalPage: 1
    }
  },
  methods: {
    beforePage: function() {
      if (this.page > 1) {
        this.page--
      }
    },
    nextPage: function() {
      if (this.page < this.totalPage) {
        this.page++
      }
    },
    pdfProcess: function(number) {
      console.log('pdfProcess', number)
    },
    overReload: function(number) {
      console.log('overReload', number)
    },
    numPages: function(number) {
      this.totalPage = number
      console.log('numPages', number)
    },
    errorReload: function(obj) {
      console.log('obj', obj)
    }
  }
}
</script>

<style>
.wrap_button {
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-between;
}

.wrap_button > div {
  width: 100px;
  background-color: deeppink;
  height: 100%;
}
</style>
